<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<!-- Mirrored from bos.asmhackers.net/docs/floppy/snippet_10/floppy.php by HTTrack Website Copier/3.x [XR&CO'2013], Tue, 07 Oct 2014 11:24:06 GMT -->
<head>

  <title>Shows the source of fdc.inc</title>


</head>
<body>

<br />

<div style="font-family: Courier New, sans-serif; font-size: 13px; margin: 5px; padding: 2px; background-color: #FFFFFF">

<br />
<br />
<span style="color: #808080">;----------------------------------------------------------;</span><br />
<span style="color: #808080">; BOS kernel &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Christoffer Bubach, 2004-2007. ;</span><br />
<span style="color: #808080">;----------------------------------------------------------;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; floppy disk driver. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">;----------------------------------------------------------;</span><br />
<br />
<br />
<br />
<span style="color: #808080">;---------------------------;</span><br />
<span style="color: #808080">; &nbsp;variables and contants &nbsp; ;</span><br />
<span style="color: #808080">;---------------------------;</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">fdd_int_done</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">dw</span><span style="color: #0000FF"> &nbsp; </span><span style="color: #008800">0</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; is the IRQ done?</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">fdd_motor_on</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">db</span><span style="color: #0000FF"> &nbsp; </span><span style="color: #008800">0</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; fdd motor on=1, off=0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">fdd_drivehead</span><span style="color: #0000FF"> &nbsp; </span><span style="color: #000000">db</span><span style="color: #0000FF"> &nbsp; </span><span style="color: #008800">0</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; ((head*4)|drive)</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">fdd_head</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">db</span><span style="color: #0000FF"> &nbsp; </span><span style="color: #008800">0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">fdd_track</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; </span><span style="color: #000000">db</span><span style="color: #0000FF"> &nbsp; </span><span style="color: #008800">0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">fdd_sector</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">db</span><span style="color: #0000FF"> &nbsp; </span><span style="color: #008800">0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">fdd_error</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; </span><span style="color: #000000">db</span><span style="color: #0000FF"> &nbsp; </span><span style="color: #008800">0</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; should we recalibrate</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; at next read/write?</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">fdd_errorcode</span><span style="color: #0000FF"> &nbsp; </span><span style="color: #000000">db</span><span style="color: #0000FF"> &nbsp; </span><span style="color: #008800">0</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">result_ST0</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">db</span><span style="color: #0000FF"> &nbsp; </span><span style="color: #008800">0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">result_ST1</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">db</span><span style="color: #0000FF"> &nbsp; </span><span style="color: #008800">0</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; or pcn</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">result_ST2</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">db</span><span style="color: #0000FF"> &nbsp; </span><span style="color: #008800">0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">result_ST3</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">db</span><span style="color: #0000FF"> &nbsp; </span><span style="color: #008800">0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">result_C</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">db</span><span style="color: #0000FF"> &nbsp; </span><span style="color: #008800">0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">result_H</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">db</span><span style="color: #0000FF"> &nbsp; </span><span style="color: #008800">0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">result_R</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">db</span><span style="color: #0000FF"> &nbsp; </span><span style="color: #008800">0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">result_N</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">db</span><span style="color: #0000FF"> &nbsp; </span><span style="color: #008800">0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">result_extra</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">db</span><span style="color: #0000FF"> &nbsp; </span><span style="color: #008800">0</span><br />
<br />
<br />
<br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #808080">; &nbsp; &nbsp;initializes the floppy disk driver &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #000000">fdc_init</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">eax</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">ebx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">ecx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">edi</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">esi</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">xor</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">eax</span><span style="color: #0000FF">, </span><span style="color: #000000">eax</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; get configuration</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0x10</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; from CMOS.</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">out</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #008800">0x70</span><span style="color: #0000FF">, </span><span style="color: #000000">al</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">in</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0x71</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">shr</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">4</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">cmp</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">4</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; a 1.44mb?</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jnz</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.no_floppy</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">cl</span><span style="color: #0000FF">, </span><span style="color: #008800">0x26</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; hook IRQ 6</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dx</span><span style="color: #0000FF">, </span><span style="color: #008800">0x8</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; CS = 8</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">edi</span><span style="color: #0000FF">, </span><span style="color: #000000">floppy_irq</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">set_int</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">cl</span><span style="color: #0000FF">, </span><span style="color: #008800">6</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; enable IRQ6</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">enable_irq</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdd_reset</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; reset FDC</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.no_floppy</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">esi</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">edi</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ecx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ebx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">eax</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">ret</span><br />
<br />
<br />
<br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp; floppy IRQ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #000000">floppy_irq</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">ds</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">eax</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">ebx</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ax</span><span style="color: #0000FF">, </span><span style="color: #008800">0x10</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ds</span><span style="color: #0000FF">, </span><span style="color: #000000">ax</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">fdd_int_done</span><span style="color: #0000FF">], </span><span style="color: #008800">1</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0x20</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">out</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #008800">0x20</span><span style="color: #0000FF">, </span><span style="color: #000000">al</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ebx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">eax</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ds</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">iret</span><br />
<br />
<br />
<br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; wait for a floppy int &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; out: &nbsp;cf &nbsp;= 1 if timeout &nbsp; ;</span><br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #000000">wait_int</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">eax</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">ecx</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ecx</span><span style="color: #0000FF">, </span><span style="color: #008800">150</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; 50 = 0.5 seconds.</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">active_delay</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; timer.inc</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.l1</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">cmp</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dword</span><span style="color: #0000FF"> [</span><span style="color: #000000">ecx</span><span style="color: #0000FF">], </span><span style="color: #008800">0</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; timeup?</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">je</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">.error</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ax</span><span style="color: #0000FF">, [</span><span style="color: #000000">fdd_int_done</span><span style="color: #0000FF">] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; if not we check for int.</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">or</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">ax</span><span style="color: #0000FF">, </span><span style="color: #000000">ax</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jz</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">.l1</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">clc</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jmp</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.end</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.error</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">stc</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.end</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ecx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">eax</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">ret</span><br />
<br />
<br />
<br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; fdd motor off &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; out: &nbsp;nothing &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #000000">fdd_off</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">cmp</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">fdd_motor_on</span><span style="color: #0000FF">], </span><span style="color: #008800">0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">je</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">.end</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">eax</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">edx</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dx</span><span style="color: #0000FF">, </span><span style="color: #008800">0x3F2</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0x0c</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; motor off</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">out</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dx</span><span style="color: #0000FF">, </span><span style="color: #000000">al</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">fdd_motor_on</span><span style="color: #0000FF">], </span><span style="color: #008800">0</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">edx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">eax</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.end</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">ret</span><br />
<br />
<br />
<br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; fdd motor on &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; out: nothing &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;</span><br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #000000">fdd_on</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">cmp</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">fdd_motor_on</span><span style="color: #0000FF">], </span><span style="color: #008800">1</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">je</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">.end</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">eax</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">edx</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dx</span><span style="color: #0000FF">, </span><span style="color: #008800">0x3F2</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; motor 0 on..</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0x1C</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">out</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dx</span><span style="color: #0000FF">, </span><span style="color: #000000">al</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ecx</span><span style="color: #0000FF">, </span><span style="color: #008800">20</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; 1/5 of a sec. to speed up</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">delay</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; in timer.inc</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">fdd_motor_on</span><span style="color: #0000FF">], </span><span style="color: #008800">1</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">edx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">eax</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.end</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">ret</span><br />
<br />
<br />
<br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #808080">; &nbsp; send a data byte to the FDC &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;in: &nbsp;al &nbsp;= data byte &nbsp;;</span><br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #000000">fdc_sendbyte</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">edx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">ecx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">eax</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ecx</span><span style="color: #0000FF">, </span><span style="color: #008800">50</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; 50 = 0.5 seconds.</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">active_delay</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; timer.inc</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.l1</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">cmp</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dword</span><span style="color: #0000FF"> [</span><span style="color: #000000">ecx</span><span style="color: #0000FF">], </span><span style="color: #008800">0</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; timeup?</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">je</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">.error</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dx</span><span style="color: #0000FF">, </span><span style="color: #008800">0x3f4</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; check status reg</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">in</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #000000">dx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">and</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0xC0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">cmp</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0x80</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; ok to write?</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jnz</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.l1</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">eax</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ecx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dx</span><span style="color: #0000FF">, </span><span style="color: #008800">0x3F5</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; send byte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">out</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dx</span><span style="color: #0000FF">, </span><span style="color: #000000">al</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">edx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">clc</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">ret</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.error</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">eax</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ecx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">edx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">stc</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">ret</span><br />
<br />
<br />
<br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #808080">; &nbsp; read a data byte from the FDC &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; out: al &nbsp;= data byte &nbsp; &nbsp; ;</span><br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #000000">fdc_getbyte</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">edx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">ecx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">eax</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ecx</span><span style="color: #0000FF">, </span><span style="color: #008800">50</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; 50 = 0.5 seconds.</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">active_delay</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; timer.inc</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.l1</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">cmp</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dword</span><span style="color: #0000FF"> [</span><span style="color: #000000">ecx</span><span style="color: #0000FF">], </span><span style="color: #008800">0</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; timeup?</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">je</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">.error</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dx</span><span style="color: #0000FF">, </span><span style="color: #008800">0x3f4</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; check status reg</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">in</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #000000">dx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">and</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0xD0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">cmp</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0xD0</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; ok to read?</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jnz</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.l1</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">eax</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ecx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dx</span><span style="color: #0000FF">, </span><span style="color: #008800">0x3F5</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; get the byte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">in</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #000000">dx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">edx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">clc</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">ret</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.error</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">eax</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ecx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">edx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">stc</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">ret</span><br />
<br />
<br />
<br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #808080">; &nbsp; sense interrupt status command &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #000000">sensei</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">eax</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0x08</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; fdc command</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_sendbyte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_getbyte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ah</span><span style="color: #0000FF">, </span><span style="color: #000000">al</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; save ST0 in ah</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_getbyte</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; read PCN</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">clc</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">test</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">ah</span><span style="color: #0000FF">, </span><span style="color: #008800">0x80</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; test for error:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jz</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">.end</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; "invalid command"</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">stc</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.end</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">eax</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">ret</span><br />
<br />
<br />
<br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #808080">; &nbsp; &nbsp;reset controller &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #000000">fdd_reset</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">eax</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">ecx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">edx</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">byte</span><span style="color: #0000FF"> [</span><span style="color: #000000">fdd_motor_on</span><span style="color: #0000FF">], </span><span style="color: #008800">0</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dx</span><span style="color: #0000FF">, </span><span style="color: #008800">0x3f2</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">8</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; off with all motors,</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">out</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dx</span><span style="color: #0000FF">, </span><span style="color: #000000">al</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; dma,irq etc..</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ecx</span><span style="color: #0000FF">, </span><span style="color: #008800">5</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">delay</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; in timer.inc</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dx</span><span style="color: #0000FF">, </span><span style="color: #008800">0x3f7</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">out</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dx</span><span style="color: #0000FF">, </span><span style="color: #000000">al</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; work at 500 kbit/s</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dx</span><span style="color: #0000FF">, </span><span style="color: #008800">0x3f2</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0x0c</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">out</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dx</span><span style="color: #0000FF">, </span><span style="color: #000000">al</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; reenable interrupts</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">fdd_int_done</span><span style="color: #0000FF">], </span><span style="color: #008800">0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">wait_int</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; wait for floppy int.</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jc</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">.error</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; timeout?</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">cx</span><span style="color: #0000FF">, </span><span style="color: #008800">0x04</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.status</span><span style="color: #0000FF">: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; 4 dummy-reads.</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">sensei</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">loop</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">.status</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0x03</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; specify command</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_sendbyte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0xDF</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; SRT, HUT</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_sendbyte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0x02</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; HLT, ND</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_sendbyte</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">1</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdd_recal_seek</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jc</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">.error</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdd_off</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">clc</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jmp</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.end</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.error</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdd_off</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">stc</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.end</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">edx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ecx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">eax</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">ret</span><br />
<br />
<br />
<br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #808080">; &nbsp;fdd_recal_seek &nbsp;- &nbsp; fdd recalibrate/seek &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">; &nbsp; in: &nbsp;al &nbsp;= 0 on seek, 1 on recalibrate &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp;bl &nbsp;= (at seek) track &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp;bh &nbsp;= (at seek) ((head*4)|drive) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #000000">fdd_recal_seek</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">eax</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdd_on</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; turn motor on</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">cmp</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jne</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.recalibrate</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">clc</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">cmp</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">bl</span><span style="color: #0000FF">, [</span><span style="color: #000000">result_C</span><span style="color: #0000FF">] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; are we there yet? :D</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">je</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">.ok</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0x0F</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; seek command</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_sendbyte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #000000">bh</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; ((head*4)|drive)</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_sendbyte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #000000">bl</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; track</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_sendbyte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">result_C</span><span style="color: #0000FF">], </span><span style="color: #000000">bl</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; now on..?</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jmp</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.get_int</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.recalibrate</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0x07</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; recalibrate command</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_sendbyte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; drive number</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_sendbyte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">result_C</span><span style="color: #0000FF">], </span><span style="color: #008800">0</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; now on track 0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.get_int</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">fdd_int_done</span><span style="color: #0000FF">], </span><span style="color: #008800">0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">wait_int</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jc</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">.error</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">sensei</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; sense interrupt status</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jc</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">.error</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">.ok</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">clc</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jmp</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.end</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.error</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">stc</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.end</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">eax</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">ret</span><br />
<br />
<br />
<br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #808080">; &nbsp;fdd_read_write &nbsp; - &nbsp;fdd read/write &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #808080">; &nbsp; input: &nbsp;bl &nbsp;= 0 read, 1 write &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch &nbsp;= track/cylinder &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cl &nbsp;= sector &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dh &nbsp;= head &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; edi = address to store or read the data &nbsp; &nbsp;;</span><br />
<span style="color: #808080">; &nbsp; output: al &nbsp;= status &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;</span><br />
<span style="color: #808080">; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cf &nbsp;= 0 if ok, 1 if error &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;</span><br />
<span style="color: #808080">;------------------------------------------------------;</span><br />
<span style="color: #000000">fdd_read_write</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pushad</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">and</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dh</span><span style="color: #0000FF">, </span><span style="color: #008800">1</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; head 0 or 1?</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">fdd_head</span><span style="color: #0000FF">], </span><span style="color: #000000">dh</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; store it.</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">shl</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dh</span><span style="color: #0000FF">, </span><span style="color: #008800">2</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">or</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">dh</span><span style="color: #0000FF">, </span><span style="color: #008800">0</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; drive 0, fd0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">fdd_drivehead</span><span style="color: #0000FF">], </span><span style="color: #000000">dh</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; dh = ((head*4)|drive)</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">fdd_errorcode</span><span style="color: #0000FF">], </span><span style="color: #008800">0x04</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; basic error code</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">cmp</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ch</span><span style="color: #0000FF">, </span><span style="color: #008800">0x51</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; check for allowed</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jae</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.error</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; track number.</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">fdd_track</span><span style="color: #0000FF">], </span><span style="color: #000000">ch</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">cmp</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">cl</span><span style="color: #0000FF">, </span><span style="color: #008800">0x13</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; check for allowed</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jae</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.error</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; sector number.</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">fdd_sector</span><span style="color: #0000FF">], </span><span style="color: #000000">cl</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">cmp</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">fdd_error</span><span style="color: #0000FF">], </span><span style="color: #008800">1</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jne</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.no_previous_error</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">1</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdd_recal_seek</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.no_previous_error</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdd_on</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dx</span><span style="color: #0000FF">, </span><span style="color: #008800">0x3F7</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; 500Kb/sec mode</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">out</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">dx</span><span style="color: #0000FF">, </span><span style="color: #000000">al</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">fdd_errorcode</span><span style="color: #0000FF">], </span><span style="color: #008800">0x80</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; error code</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">xor</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ecx</span><span style="color: #0000FF">, </span><span style="color: #000000">ecx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">cx</span><span style="color: #0000FF">, </span><span style="color: #008800">3</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; try seek 3 times</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.l2</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">ebx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">bl</span><span style="color: #0000FF">, [</span><span style="color: #000000">fdd_track</span><span style="color: #0000FF">]</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">bh</span><span style="color: #0000FF">, [</span><span style="color: #000000">fdd_drivehead</span><span style="color: #0000FF">] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; ((head*4)|drive)</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdd_recal_seek</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ebx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jnc</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.l3</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; ok, continue.</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">loop</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">.l2</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jmp</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.error</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; timeout.</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.l3</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">ebx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">cmp</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">bl</span><span style="color: #0000FF">, </span><span style="color: #008800">0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">je</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">.read_fdd</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.write_fdd</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">push</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">edi</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">esi</span><span style="color: #0000FF">, </span><span style="color: #000000">edi</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">edi</span><span style="color: #0000FF">, </span><span style="color: #008800">0x80000</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; copy the stuff we will</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ecx</span><span style="color: #0000FF">, </span><span style="color: #008800">128</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; write to the DMA buffer</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">rep</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">movsd</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; 128*4=512</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">edi</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">bl</span><span style="color: #0000FF">, </span><span style="color: #008800">2</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; channel 2</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">esi</span><span style="color: #0000FF">, </span><span style="color: #008800">512</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; bytes to write</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ecx</span><span style="color: #0000FF">, </span><span style="color: #008800">0x80000</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; page & offset</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">bh</span><span style="color: #0000FF">, </span><span style="color: #008800">1</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; write floppy, read DMA</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">dma_transfer</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0xC5</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; write sector command</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_sendbyte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jmp</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.cont</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.read_fdd</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">bl</span><span style="color: #0000FF">, </span><span style="color: #008800">2</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; channel 2</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">esi</span><span style="color: #0000FF">, </span><span style="color: #008800">512</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; bytes to read</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ecx</span><span style="color: #0000FF">, </span><span style="color: #008800">0x80000</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; page & offset</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">bh</span><span style="color: #0000FF">, </span><span style="color: #008800">0</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; read floppy, write DMA</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">dma_transfer</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0xE6</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; read sector command</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_sendbyte</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.cont</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">pop</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ebx</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, [</span><span style="color: #000000">fdd_drivehead</span><span style="color: #0000FF">] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; ((head*4)|drive)</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_sendbyte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, [</span><span style="color: #000000">fdd_track</span><span style="color: #0000FF">] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; track/cylinder</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_sendbyte</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, [</span><span style="color: #000000">fdd_head</span><span style="color: #0000FF">] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; head/side 0 or 1</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_sendbyte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, [</span><span style="color: #000000">fdd_sector</span><span style="color: #0000FF">] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; sector number</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_sendbyte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0x02</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; sector size, 512 bytes</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_sendbyte</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0x12</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; sectors to a track</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_sendbyte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0x1B</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; gap length</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_sendbyte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, </span><span style="color: #008800">0xFF</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; data length</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_sendbyte</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">fdd_int_done</span><span style="color: #0000FF">], </span><span style="color: #008800">0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">wait_int</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jc</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">.error</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_getbyte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">result_ST0</span><span style="color: #0000FF">], </span><span style="color: #000000">al</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; ST0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_getbyte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">result_ST1</span><span style="color: #0000FF">], </span><span style="color: #000000">al</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; ST1</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_getbyte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">result_ST2</span><span style="color: #0000FF">], </span><span style="color: #000000">al</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; ST2</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_getbyte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">result_C</span><span style="color: #0000FF">], </span><span style="color: #000000">al</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; cylinder</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_getbyte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">result_H</span><span style="color: #0000FF">], </span><span style="color: #000000">al</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; head</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_getbyte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">result_R</span><span style="color: #0000FF">], </span><span style="color: #000000">al</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; sector number.</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdc_getbyte</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">result_N</span><span style="color: #0000FF">], </span><span style="color: #000000">al</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; sector size</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">test</span><span style="color: #0000FF"> &nbsp; &nbsp;[</span><span style="color: #000000">result_ST0</span><span style="color: #0000FF">], </span><span style="color: #008800">0xc0</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; test if sr0 is 0xC0</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jnz</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.error</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">cmp</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">bl</span><span style="color: #0000FF">, </span><span style="color: #008800">1</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; did we write the disk?</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">je</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">.ok</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">ecx</span><span style="color: #0000FF">, </span><span style="color: #008800">512</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; sector size in bytes</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">esi</span><span style="color: #0000FF">, </span><span style="color: #008800">0x80000</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; copy to dest. in edi</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">rep</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">movsb</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.ok</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">fdd_errorcode</span><span style="color: #0000FF">], </span><span style="color: #008800">0</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; no error.. :D</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">fdd_error</span><span style="color: #0000FF">], </span><span style="color: #008800">0</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; no recal. next time</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">clc</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">jmp</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.end</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.error</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; [</span><span style="color: #000000">fdd_error</span><span style="color: #0000FF">], </span><span style="color: #008800">1</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #808080">; recalibrate next time</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">stc</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">.end</span><span style="color: #0000FF">:</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">call</span><span style="color: #0000FF"> &nbsp; &nbsp;</span><span style="color: #000000">fdd_off</span><span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; floppy motor off</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">popad</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">mov</span><span style="color: #0000FF"> &nbsp; &nbsp; </span><span style="color: #000000">al</span><span style="color: #0000FF">, [</span><span style="color: #000000">fdd_errorcode</span><span style="color: #0000FF">] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #808080">; error status</span><br />
<span style="color: #0000FF"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #000000">ret</span><br />
<br />
<span style="color: #0000FF"> &nbsp; &nbsp;</span><br />

</div>

<br />

</body>

<!-- Mirrored from bos.asmhackers.net/docs/floppy/snippet_10/floppy.php by HTTrack Website Copier/3.x [XR&CO'2013], Tue, 07 Oct 2014 11:24:06 GMT -->
</html>